function checkPLIoverTrials(inDir,outDir)

bandlabels={'raw','delta','theta','alpha','beta','gamma'};

for i=1:length(bandlabels)
    
    filter=strcat('pli_',bandlabels{i});
    filter=strcat(filter,'*_A8*')
    subjs=dir(fullfile(inDir,filter));
    nsubjs=length(subjs);
    
     
     load(fullfile(inDir,subjs(1).name));
     [nTrial,nch,nch2]=size(pliXT);
    
     
    avgPLI_one=zeros(nsubjs,nTrial);
    avgPLI_two=zeros(nsubjs,nTrial);

   
    for j=1:length(subjs)
        
        subjName=subjs(j).name;
        load(fullfile(inDir,subjName));
        
        avgPLI_one(j,:)=myMean(pliXT);

       
        
        [subjName,dot]=strtok(subjName,'.');
        
        subjName(end)='B';
        subjName=strcat(subjName,dot)
        load(fullfile(inDir,subjName));
        
        avgPLI_two(j,:)=myMean(pliXT);
    end
    
    save(fullfile(outDir,strcat('pliXsubjs_',bandlabels{i})),'avgPLI_one','avgPLI_two');
end

